################
#PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
#
#Observational Analysis ESS
#Figure B 9
#
#Verena Fetscher
#July 2022
####################

####################
# Load data
####################
source("dataframes.R")


##########################
#Benefit concentration indicators versus alternative measures: Benefit concentration and target efficiency by Mahler and Jesuit (2006)
##########################
data_sub$efficiency<-NA
data_sub$efficiency[data_sub$country=="Belgium"]<- -0.125
data_sub$efficiency[data_sub$country=="Sweden"]<- -0.062
data_sub$efficiency[data_sub$country=="Netherlands"]<- -0.015
data_sub$efficiency[data_sub$country=="Finland"]<- -0.134
data_sub$efficiency[data_sub$country=="France"]<- 0.053
data_sub$efficiency[data_sub$country=="Denmark"]<- -0.142
data_sub$efficiency[data_sub$country=="Germany"]<- -0.223
data_sub$efficiency[data_sub$country=="United Kingdom"]<- -0.281
data_sub$efficiency[data_sub$country=="Norway"]<- -0.246
data_sub$efficiency[data_sub$country=="Switzerland"]<- -0.059

cor.test(data_sub$efficiency,data_sub$benefitsAvg, method=c("pearson"))

##########################
# Produces Figure B.9: Benefit concentration and internal target efficiency of social benefits.
##########################


data_sub%>%
  group_by(country)%>%
  filter(year==2002)%>%
  summarize(benefits=mean(benefitsAvg),
            efficiency=mean(efficiency,na.rm=T))%>%
  ggplot(aes(x=benefits, y=efficiency)) + 
  geom_point() + 
  ggtitle("Benefit concentration and fiscal redistribution (via transfers)") + 
  geom_smooth(method=lm, se=T) + 
  scale_x_continuous(name = "Benefit concentration", limits = c(0, 1)) + 
  scale_y_continuous(name = "Target efficiency") + 
  theme_bw()


##########################
#Save figure
##########################

ggsave(file="figure_b9.pdf", height = 5.83, width = 8.27, units = "in")


